﻿using System;
using System.Security.Cryptography;
namespace MEthod
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 1, b = 2;
            var result = Add(a, b);
            Console.WriteLine(result);

            Swap1(a, b);
            Console.WriteLine($"a = {a}, b = {b}");

            Swap2(ref a, ref b);
            Console.WriteLine($"a = {a}, b = {b}");

            fun1(a, b, out int c, out int d);
            Console.WriteLine($"a + b = {c}, a - b = {d}");

            fun2(out int x, out string str, out bool bflag);
            Console.WriteLine($"x = {x}, str = {str}, bflag = {bflag}");

            var result1 = Divide(a, b);
            Console.WriteLine($"Result = {result1.Result}, Remainder = {result1.Remainder}");

            Mypoint("hello!");
            Mypoint(89);
            var res1 = Mypoint(55, 32);
            Console.WriteLine(res1);

            string st1 = "hello";
            string st2 = "wzy";
            Swap3<string>(ref st1, ref st2);
            Console.WriteLine($"a = {st1}, b = {st2}");

            int i1 = 3, i2 = 4;
            Swap3<int>(ref i1, ref i2);
            Console.WriteLine($"a = {i1},b = {i2}");

            Console.ReadKey();

        }

        static int Add(int x, int y)
        {
            int c = x + y;
            x = 23;
            y = 22;
            return c;
        }

        public static void Swap1(int x, int y)
        {
            int tmp = x;
            x = y;
            y = tmp;
        }

        public static void Swap2(ref int x, ref int y)
        {
            int tmp = x;
            x = y;
            y = tmp;
        }

        static void fun1(int x, int y, out int c, out int d)
        {
            c = x + y;
            d = x - y;
        }

        static void fun2(out int a, out string b, out bool c)
        {
            a = 234;
            b = "wdnmd";
            c = true;   
        }

        static (int Result, int Remainder) Divide(int x, int y)
        {
            int result, remainder;
            result = x / y;
            remainder = x % y;
            return(result, remainder );
        }

        static void Mypoint(string s)
        {
            Console.WriteLine(s);
        }

        static void Mypoint(int i)
        {
            Console.WriteLine(i);
        }

        static int Mypoint(int a, int b)
        {
            return a + b;
        }

        static void Swap3<T>(ref T x, ref T y)
        {
            T tmp = x;
            x = y;
            y = tmp;
        }
    }
}